/**
 * 商品相关API
 */

import {
	http,
	Method
} from "@/utils/request.js";
// /buyer/store/applyBuyer 商家入驻
export function ApplyBuyer(data) {
	return http.request({
		url: `/store/applyBuyer`,
		method: Method.PUT,
		params: data
	});
}
// 好店推荐列表
export function getGoodsShopList() {
	return http.request({
		url: "/goods/storeStatistics",
		method: Method.GET,
	});
}
/**
 * 从ES中获取相关商品品牌名称，分类名称及属性
 */
export function getGoodsMessage(goodsId) {
	return http.request({
		url: `/goods/get/${goodsId}`,
		method: Method.GET,
	});
}

/**
 * 从ES中获取相关商品品牌名称，分类名称及属性
 */
export function getGoodsRelated(params) {
	return http.request({
		url: `/goods/es/related`,
		method: Method.GET,
		params,
	});
}

/**
 * 获取商品详情
 * @param skuId 商品ID
 * @returns {AxiosPromise}
 */
export function getGoods(skuId, goodsId) {
	return http.request({
		url: `/goods/sku/${goodsId}/${skuId}`,
		method: Method.GET,
	});
}
/**
 * 浏览商品插入足迹
 * @param {*} skuId  商品ID
 * @param {*} goodsId  
 */
export function browseInsSpoor(skuId, goodsId) {
	return http.request({
		url: `/footprint/add`,
		method: Method.POST,
		params: {
			skuId,
			goodsId,
		}
	});
}
/**
 * 获取商品分销
 * @param distributionId 商品分销ID
 */
export function getGoodsDistribution(distributionId) {
	return http.request({
		url: `/distribution/bindingDistribution/${distributionId}`,
		method: Method.GET,
	});
}


/**
 * 获取商品列表
 * @param params
 * @returns {AxiosPromise}
 */
export function getGoodsList(params) {
	return http.request({
		url: "/goods/getGoodsByStore",
		method: Method.GET,
		params,
	});
}
/**
 * 热词搜索
 * @param params
 * @returns {AxiosPromise}
 */
export function hotWordSearch(params) {
	return http.request({
		url: "/goods/hot-words",
		method: Method.GET,
		params,
	});
}
/**
 * 获取店铺列表
 * @param params
 * @returns {AxiosPromise}
 */
export function getShopList(params) {
	return http.request({
		url: "/pageData/getCommodityShop",
		method: Method.GET,
		params,
	});
}
/**
 * 获取全城
 * @param params
 * @returns {AxiosPromise}
 */
export function getRegionList(params) {
	return http.request({
		url: "/region/adcode",
		method: Method.GET,
		params,
	});
}
/**
 * 获取今日爆品商品列表
 * @param params
 * @returns {AxiosPromise}
 */
export function getHotGoodsList() {
	return http.request({
		url: "/goods/goodsStatistics",
		method: Method.GET,
	});
}
/**
 * 获取上新商品列表
 * @param params
 * @returns {AxiosPromise}
 */
export function getGoodsListUplog(params) {
	return http.request({
		url: "goods/search/uplog",
		method: Method.GET,
		params,
	});
}



/**
 * 获取标签商品
 * @param storeId 卖家id
 * @param mark      标签 hot：热卖 new：新品 recommend：推荐
 * @param num       获取个数
 */
export function getTagGoods(storeId, mark = "hot", num = 5) {
	return http.request({
		url: `goods/tags/${mark}/goods`,
		method: Method.GET,
		loading: false,
		params: {
			storeId,
			mark,
			num,
		},
	});
}
/**
 * 获取标签商品
 */
export function getPlateformTagGoods(tag_id) {
	return http.request({
		url: `goods/tags/byid/${tag_id}`,
		method: Method.GET,
		loading: false,
	});
}

/**
 * 获取首页商品分类 左侧列表
 * @param parent_id
 */
export function getCategoryList(id) {
	return http.request({
		url: `/category/get/${id}`,
		method: Method.GET,
		loading: false,
	});
}




/**
 * 获取当前会员的分销商信息 可根据分销商信息查询待提现金额以及冻结金额等信息
 */
export function distribution() {
	return http.request({
		url: `/distribution`,
		method: Method.GET,
	});
}

/**
 * 申请分销商
 */
export function applyDistribution(params) {
	return http.request({
		url: `/distribution`,
		method: Method.POST,
		params,
	});
}

/**
 * 分销商提现
 */
export function cash(params) {
	return http.request({
		url: `/distribution/cash`,
		method: Method.POST,
		params,
	});
}

/**
 * 分销商提现历史
 */
export function cashLog(params) {
	return http.request({
		url: `/distribution/cash`,
		method: Method.GET,
		params

	});
}

/**
 * 获取分销商分页订单列表
 */
export function distributionOrderList(params) {
	return http.request({
		url: `/distribution/distributionOrder`,
		method: Method.GET,
		params
	});
}

/**
 * 获取分销商商品列表
 */
export function distributionGoods(params) {
	return http.request({
		url: `/distributionGoods`,
		method: Method.GET,
		params,
	});
}
/**
 * 选择分销商品 分销商品id
 */
export function checkedDistributionGoods(params) {
	return http.request({
		url: `/distributionGoods/checked/${params.id}`,
		method: Method.GET,
		params
	});
}

/**
 * 获取 小程序码
 */
export function getMpCode(params) {
	return http.request({
		url: `/mini-program/mp/unlimited`,
		method: Method.GET,
		params
	})
}

/**
 * 根据shortlink 获取页面参数
 */
export function getMpScene(id) {
	return http.request({
		url: `/mini-program/mp/unlimited/scene?id=${id}`,
		method: Method.GET,

	})
}


// 个人信息数据反显接口
export function userInfo() {
	return http.request({
		url: `/partner/getPartner`,
		method: Method.GET
	})
}

// 申请成为合伙人提交接口

export function getaddPartner(data) {
	return http.request({
		url: `/partner/addPartner`,
		method: Method.POST,
		params: data,
	});
}

// 商品评论详情

export function goodsComment(data) {
	return http.request({
		url: `/orders/comment/${data.sn}/${data.id}`,
		method: Method.GET
	});
}
// 获取商品计量单位
export function goodsUnit(data) {
	return http.request({
		url: `/goods/unit`,
		method: Method.GET
	});
}
// 查询运费模板
export function getShipTemplate(data) {
	return http.request({
		url: `/freightTemplate`,
		method: Method.GET
	});
}
//合伙人入驻-身份证 ocr
export function getCertificateIdentification(data) {
	return http.request({
		url: `/partner/getCertificateIdentification?url=` + data.url,
		method: Method.GET
	});
}
// 获取端口费用
export function partnerPrice(data) {
	return http.request({
		url: `/sysDict/partnerPrice?partner=` + data.type,
		method: Method.GET
	});
}
// 获取店铺分类
export function GetStoreCategory() {
	return http.request({
		url: '/category/label'
	})
}
// 上传商品
export function UploadGoods(params) {
	return http.request({
		url: '/goods/create',
		method: Method.POST,
		data: params
	})
}
// 海报太阳码
export function SunCode(link) {
	return http.request({
		url: '/extension/mp/unlimited',
		method: Method.GET,
		params: {
			scene: link,
			page: 'pages/product/customerservice/index'
		}
	})
}
// 实物商品更多页面新品列表
export function newGoods(params) {
	return http.request({
		url: `/pageData/newGoods`,
		method: Method.GET,
		params
	});
}
/**
 * 推荐的商品列表，根据当前商品推荐同类别
 */
export function ShopListrRecommend(params) {
	return http.request({
		url: `/goods/getGoodsListByPage`,
		method: Method.GET,
		params
	});
}
